package org.lzfto.flink.demo.business.flinkTest.flinkObjects.selector;

import org.apache.flink.api.java.functions.KeySelector;
import org.lzfto.flink.demo.business.orders.OrderKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 订单选择器
 * <br/>
 * <br/>根据不同的构造函数而有不同的表现。
 * <br/>如果构造函数参数useSalt=true,那么会在生成key的时候，去掉数据生成过程中添加的盐
 */
public class OrderMixedSelector<T extends OrderKey> implements KeySelector<T, OrderMixedKey> {
	private static final long serialVersionUID = 1L;
	
	private final  Logger LOGGER = LoggerFactory.getLogger(getClass());
	
	private String grpType;
	
	public OrderMixedSelector(String grpType) {
		this.grpType=grpType;
		LOGGER.info("创建订单选择器,分组类型:{}",grpType);
	}
 
	
	@Override
	public OrderMixedKey getKey(T value) throws Exception {
		OrderMixedKey key = new OrderMixedKey(grpType, value.getZoneName(), value.getSex());
		return key;
	}

	public String getGrpType() {
		return grpType;
	}

	public void setGrpType(String grpType) {
		this.grpType = grpType;
	}
}
